﻿<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" default-lazy="true" namespace="Cms.Domain" assembly="Cms.Domain">
  <class name="Permission" table="cmsPermission">
    <cache usage="read-write" />
    <id name="ID" type="System.Int32" unsaved-value="0">
      <column name="ID" />
      <generator class="assigned" />
    </id>
    <property name="Name" type="System.String">
      <column name="Name" length="255" not-null="true" />
    </property>
    <property name="SortIndex" type="System.Int32">
      <column name="SortIndex" not-null="true" />
    </property>
    <many-to-one class="Permission" name="Parent">
      <column name="ParentID" />
    </many-to-one>
    <bag cascade="save-update" fetch="join" inverse="true" name="SubPermissions" mutable="true" order-by="SortIndex">
      <cache usage="read-write" />
      <key>
        <column name="ParentID" />
      </key>
      <one-to-many class="Permission" />
    </bag>
    <bag name="Groups" table="cmsAdministratorGroupPermission" mutable="true">
      <cache usage="read-write" />
      <key>
        <column name="PermissionID" />
      </key>
      <many-to-many class="AdministratorGroup">
        <column name="GroupID" />
      </many-to-many>
    </bag>
  </class>
</hibernate-mapping>